Consider the Hock-Schittkowski problem, which is defined as follows:
Formulation:
$$ \left.\begin{array}{rrcl} \min & z = x_1x_4(x_1 + x_2 + x_3) + x_3 \\ \text {s.t.:} & & & \\ \text{(1)} & x_1x_2x_3x_4 \geq 25\\ \text{(2)} & x^2_1 + x^2_2 +x^2_3 +x^2_4 = 40\\ \text{(3)} & 1 \leq x_1,x_2,x_3,x_4 \leq 5 \end{array}\right\} $$What is the (rounded) optimal solution?
In [5]:
using JuMP
using NLopt
m = Model(solver=NLoptSolver(algorithm=:LD_SLSQP))
# Adding Variables
@variable(m, 1 <= x[1:4] <= 5)
print(m)
# Adding nonlinear constraints
@NLconstraint(m, x[1] * x[2] * x[3] * x[4] >= 25)
@NLconstraint(m, x[1]^2 * x[2]^2 * x[3]^2 * x[4]^2 == 40)
# Adding nonlinear objective
@NLobjective(m, Min, x[1] * x[4] * (x[1] + x[2] + x[3]) + x[3])
solve(m)
In [ ]: